using System.Data;
using ET;

namespace DAL
{
    public class Inventory_DAL
    {
        private static readonly clsConnect cls = new clsConnect();

        #region Getdata
        public DataTable Search(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KEYWORDS", keywords);
            return cls.GetData("sp_tb_Inventory_Search");
        }
        public DataTable BindGirdtb_InventoryDetail(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Inventory_ID", id);
            return cls.GetData("sp_tb_Inventory_SelectRow");
        }
        public static DataTable GetInventoryFillterDate(string dateBegin, string dateEnd)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@DateBegin", dateBegin);
            cls.AddParameter("@EndBegin", dateEnd);
            return cls.GetData("sp_tb_Inventory_FillterDate");
        }
        public static DataTable GetInventoryFillter(string warehouseId, string roomId)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Warehouse_Id", warehouseId);
            cls.AddParameter("@Room_ID", roomId);
            return cls.GetData("sp_tb_Inventory_Fillter");
        }
        #endregion

        #region Insert
        public bool Inserttb_Inventory(Inventory_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Inventory_No", data.Inventory_No);
            cls.AddParameter("@Inventory_Date", data.Inventory_Date);
            cls.AddParameter("@Room_ID", data.Room_ID);
            cls.AddParameter("@Warehouse_ID", data.Warehouse_ID);
            cls.AddParameter("@Inventory_Note", data.Inventory_Note);
            cls.AddParameter("@Inventory_Test", data.Inventory_Test);
            cls.AddParameter("@Inventory_User_Add", data.Inventory_User_Add);
            cls.AddParameter("@Inventory_Date_Add", data.Inventory_Date_Add);
            cls.AddParameter("@Inventory_Computer_Add", data.Inventory_Computer_Add);
            data.Inventory_ID = cls.ExecuteNonQueryReturnResult("sp_tb_Inventory_Insert", "@ReferenceID");
            return true;
        }
        #endregion

        #region Update
        public bool Updatetb_Inventory(Inventory_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Inventory_ID", data.Inventory_ID);
            cls.AddParameter("@Inventory_No", data.Inventory_No);
            cls.AddParameter("@Inventory_Date", data.Inventory_Date);
            cls.AddParameter("@Room_ID", data.Room_ID);
            cls.AddParameter("@Warehouse_ID", data.Warehouse_ID);
            cls.AddParameter("@Inventory_Note", data.Inventory_Note);
            cls.AddParameter("@Inventory_Test", data.Inventory_Test);
            cls.AddParameter("@Inventory_User_Modify", data.Inventory_User_Modify);
            cls.AddParameter("@Inventory_Date_Modify", data.Inventory_Date_Modify);
            cls.AddParameter("@Inventory_Computer_Modify", data.Inventory_Computer_Modify);
            return cls.ExecuteNonQuery("sp_tb_Inventory_Update");
        }
        #endregion

        #region Delete
        public bool Deletetb_Inventory(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Inventory_ID", id);
            return cls.ExecuteNonQuery("sp_tb_Inventory_Delete");
        }
        #endregion
    }
}